require([
  "jquery",
  "dodo",
  "components/loader/jq-loader"
], function ($, dodo, loader) {
  'use strict';
  $(function () {
    var $wrapper = $('.wrapper');
    loader.show($wrapper);

    /**
     * 内容控制器
     */
    var contentFrameController = {
      $el: $('iframe[data-zone="content-frame"]', document),
      changeSrc: function (url) {
        if (dodo.notEmptyTrimmedString(url)) {
          this.$el.attr('src', url);
        }
      },
      height: function () {
        var docHeight = $(document).height();
        var frameOffset = this.$el.offset();
        var footerHeight = $('.main-footer').outerHeight(true);
        var frameBodyPadding = 16;
        this.$el.height(docHeight - frameBodyPadding - frameOffset.top - footerHeight);
      }
    };

    contentFrameController.height();
    var sideBarController = {
      $el: $('.sidebar-menu', document)
    };
    sideBarController.$el.on('click', 'li a', function (event) {
      var url = $(this).attr('data-link');
      if (dodo.notEmptyTrimmedString(url)) {
        contentFrameController.changeSrc(url);
      }
    });

    loader.hide($wrapper);
  });
});
